package com.oa.test;

import java.util.Random;

public class RandomNumber {
	public static void main(String[] args) {
		randomNumber1();
		
		randomNumber2();
		
		randomNumber3();
	}
	
	//方法一：
	static void randomNumber1() {
		Random r = new Random();
		for (int i = 0; i < 5; i++) {
			int ran1 = r.nextInt(100);
			System.out.print(ran1+"   ");
		}
		System.out.println("\n");
	}
	
	//方法二：
	static void randomNumber2() {
		int max = 100, min = 1;
		int ran2 = (int) (Math.random() * (max - min) + min);
		System.out.print(ran2+"   ");
		System.out.println("\n");
	}
	
	//方法三：
	static void randomNumber3(){
	       int max=100,min=1;
	       long randomNum = System.currentTimeMillis();  
	       int ran3 = (int) (randomNum%(max-min)+min);  
	       System.out.print(ran3+"   ");
	       System.out.println("\n");
	}
}
